import { getStore, removeStore, setStore } from '@/util/store'

const common = {
  state: {
    isFullScren:false,
    isCollapse: false,
    showCollapse: true,
    showFullScren: true,
    addRoutes:getStore({
      name: 'ADD_ROUTES'
    }) || '',
    theme: getStore({ name: 'theme' }) || '#409EFF',
  },
  actions: {},
  mutations: {
    SET_COLLAPSE: (state) => {
      state.isCollapse = !state.isCollapse
    },
    SET_FULLSCREN: (state) => {
      state.isFullScren = !state.isFullScren
    },
    SET_SHOWCOLLAPSE: (state, active) => {
      console.log(active);
      state.showCollapse = active
      setStore({
        name: 'showCollapse',
        content: state.showCollapse
      })
    },
    SET_SHOWFULLSCREN: (state, active) => {
      state.showFullScren = active
      setStore({
        name: 'showFullScren',
        content: state.showFullScren
      })
    },
    ADD_ROUTES: (state,active) => {
      state.addRoutes = active
      console.log(active);
      setStore({
        name: 'ADD_ROUTES',
        content: state.addRoutes
      })
    },
    SET_THEME: (state, color) => {
      state.theme = color
      setStore({
        name: 'theme',
        content: state.theme
      })
    },
  }
}

export default common